//
//  OtherIndexTableViewController.m
//  cutter
//
//  Created by mac on 16/3/2.
//  Copyright © 2016年 e360. All rights reserved.
//
#import "OtherSale.h"
#import "OtherCart.h"
#import "OtherFavoriteCtrl.h"
#import "OtherPlanCtrl.h"
#import "OtherSchemeCtrl.h"
#import "OtherMatchCtrl.h"
#import "OtherCenter.h"

@interface OtherCenterMasterCell : UITableViewCell
@property(nonatomic, weak) IBOutlet UIImageView *thumbView;
@property(nonatomic, copy) IBInspectable NSString *activeImage;
@property(nonatomic, copy) IBInspectable NSString *nomalImage;
@end
@implementation OtherCenterMasterCell
-(void)setSelected:(BOOL)selected animated:(BOOL)animated{
    [super setSelected:selected animated:animated];
    if (selected) {
        UIImage *img = [UIImage imageNamed:self.activeImage];
        [self.thumbView setImage:img];
    }else{
        UIImage *img = [UIImage imageNamed:self.nomalImage];
        [self.thumbView setImage:img];
    }
}
@end

//
@interface OtherCenterMaster : UITableViewController
@end
@implementation OtherCenterMaster
-(void)viewDidLoad{
    [super viewDidLoad];
    [self setClearsSelectionOnViewWillAppear:NO];
}
-(IBAction)exitTouch:(id)sender{
    if (self.splitViewController) {
        [self.splitViewController dismissViewControllerAnimated:YES completion:nil];
    }else{
        [self dismissViewControllerAnimated:YES completion:nil];
    }
}
@end

//
@implementation OtherCenter
-(void)viewDidLoad{
    [self setMinimumPrimaryColumnWidth:76];
    [self setMaximumPrimaryColumnWidth:76];
    if (self.userCenterCtrl) {
        [self setSelectedIndex:self.userCenterCtrl.selectedIndex];
    }
}
-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    [self.bgView setFrame:self.view.bounds];
    [self.view insertSubview:self.bgView atIndex:0];
}
-(void)setSelectedIndex:(NSInteger)index{
    UINavigationController *root = [self.viewControllers firstObject];
    if (root && [root isKindOfClass:UINavigationController.class]) {
        UITableViewController *master = [root.viewControllers firstObject];
        if (master) {
            NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
            [master.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
            //
            NSString *identifier = [NSString stringWithFormat:@"segue%ld", (long)index];
            [master performSegueWithIdentifier:identifier sender:nil];
        }
    }
}
@end
